import Vue from 'vue'

// 提交以后禁用按钮一段时间，防止重复提交
Vue.directive('preventReClick', {
  inserted(el, binding) {
    el.addEventListener('click', e => {
      el.classList.add('is-disabled')
      el.disabled = true
      setTimeout(() => {
        el.disabled = false
        el.classList.remove('is-disabled')
      }, binding.value || 1000)
    })
  }
})
